package book;

public class BookList {

    private Book[] books = new Book[10];
    private int usedSize;//记录当前books数组当中 有多少本书

    //这里默认放了3本书
    public BookList() {
        books[0] = new Book("三国演义","罗贯中","小说",69);
        books[1] = new Book("西游记","吴承恩","小说",79);
        books[2] = new Book("红楼梦","曹雪芹","小说",59);
        this.usedSize = 3;
    }

    public Book getBook(int pos) {
        return this.books[pos];
    }

    //这里两个setBook方法构成重载
    //增加图书功能要用到
    public void setBook(Book book) {
        this.books[usedSize] = book;
    }

    //删除图书时，将后面的图书往前移会用到
    public void setBook(int pos,Book book) {
        this.books[pos] = book;
    }

    public int getUsedSize() {
        return usedSize;
    }

    public void setUsedSize(int usedSize) {
        this.usedSize = usedSize;
    }
}
